class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-03-24",
      revision: "498e749e36c3b2d097fe6dbd104b772a680f21ed"
  version "2022-03-24"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "1a55f628feb6bb73e046b23b4a2adb965eee3486acf6c73e211ea676ece88a47"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "51f35fcc0d77ad9d6b6637e225382f78a80aa0daeca4fa7676631a4fa28237f6"
    sha256 cellar: :any_skip_relocation, monterey:       "19c72aea82f4e258b3065e2260f458760d528e1de23b141efa4cfd3e77f8ea90"
    sha256 cellar: :any_skip_relocation, big_sur:        "87c1ab46680924abe0bea752f1221a0296c445c8ef6699d21f84aa7b805e434b"
    sha256 cellar: :any_skip_relocation, catalina:       "0353c08ffe9dac84c6813a9288acd6bfb836e6d0356ff862099e0527219ce013"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "1ad58c943984aa301ae86c8b685ffb7c96090b803c5060f640c4742c54a5cf26"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
